﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QLThuVien
{
    class DocGia
    {
        string madg, hotendg, madtdg,gioitinh, diachi;
        DateTime ngaysinh ;

        public DocGia() { }
        public DocGia(string madg, string madtdg, string hotendg, string gioitinh, DateTime ngaysinh, string diachi)
        {
            this.diachi = diachi;
            this.hotendg = hotendg;
            this.gioitinh = gioitinh;
            this.madg = madg;
            this.madtdg = madtdg;
            this.ngaysinh = ngaysinh;            
        }
        
        #region cac phuong thuc set
        public void set_madtdg(string madtdg)
        {
            this.madtdg = madtdg;
        }

        public void set_gioitinh(string gioitinh)
        {
            this.gioitinh = gioitinh;
        }

        public void set_hotendg(string hotendg)
        {
            this.hotendg = hotendg;
        }

        public void set_diachi(string diachi)
        {
            this.diachi = diachi;
        }

        public void set_madg(string madg)
        {
            this.madg = madg;
        }
               
        public void set_ngaysinh(DateTime ngaysinh)
        {
            this.ngaysinh = ngaysinh;
        }

        #endregion

        #region cac phuong thuc get
        public string get_madtdg()
        {
            return madtdg;
        }

        public string get_gioitinh()
        {
            return gioitinh;
        }

        public string get_diachi()
        {
            return diachi;
        }
        
        public string get_hotendg()
        {
            return hotendg;
        }

        public string get_madg()
        {
            return madg;
        }
                
        public DateTime get_ngaysinh()
        {
            return ngaysinh;
        }

        #endregion
        public bool taomoi()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("insert into DOCGIA values('" + madg + "','" + madtdg + "',N'" + hotendg + "','" + gioitinh + "','" + ngaysinh + "','" + diachi + "')") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }

            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }
        public bool capnhat()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
                                     
            if (txdl.thucthitruyvan("update docgia set HOTEN=N'" + hotendg + "',MALOAIDOCGIA='" + madtdg + "',gioitinh='" + gioitinh + "',ngaysinh='" + ngaysinh + "',diachi=N'" + diachi + "' where MADOCGIA='" + madg + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }
        public bool xoabo()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("delete from docgia where MADOCGIA='" + madg + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }
        
    }
}
